package com.tjnmt.togo.utils.BaiduMapUtil;

import com.baidu.mapapi.search.route.BikingRoutePlanOption;
import com.baidu.mapapi.search.route.PlanNode;
import com.baidu.mapapi.search.route.RoutePlanSearch;
import com.tjnmt.togo.Interface.Locationable;
import com.tjnmt.togo.listener.MyRoutePlanListener;

/**
 * 路线检索工具类。
 *此处将根据后续服务端返回的用户位置数据来更新另外两个重载方法。
 */
public class RoutePlanUtil {
    private static final RoutePlanSearch routePlanSearch;

    static {
        routePlanSearch = RoutePlanSearch.newInstance();
        routePlanSearch.setOnGetRoutePlanResultListener(new MyRoutePlanListener());
    }

    public static void  bikeSearch(Locationable locationable){
        PlanNode start = PlanNode.withLocation(locationable.getStartLocation());
        PlanNode end = PlanNode.withLocation(locationable.getEndLocation());

        routePlanSearch.bikingSearch(new BikingRoutePlanOption().from(start).to(end));
    }

    public static void bikeSearch(PlanNode start,PlanNode end){
        routePlanSearch.bikingSearch(new BikingRoutePlanOption().from(start).to(end));
    }
}
